//
// Pyramide.cpp for bmoberman in /home/noboa_y//noboa-y-global/yn
//
// Made by youri noboa
// Login   <noboa_y@epitech.net>
//
// Started on  Fri Apr 20 15:07:35 2012 youri noboa
// Last update Wed Apr 25 15:54:46 2012 youri noboa
//

#include	"Cube.hh"

namespace	Object
{
  void Pyramide::initialize(void)
  {
  }

  void Pyramide::update(const gdl::GameClock &gameClock, gdl::Input &input)
  {
    (void)gameClock;
    if (input.isKeyDown(gdl::Keys::Right))
      this->rotation_.y = ((int)rotation_.y + 10) % 360;
    if (input.isKeyDown(gdl::Keys::Left))
      this->rotation_.y = ((int)rotation_.y - 10) % 360;
    if (input.isKeyDown(gdl::Keys::Up))
      this->rotation_.x = ((int)rotation_.x - 10) % 360;
    if (input.isKeyDown(gdl::Keys::Down))
      this->rotation_.x = ((int)rotation_.x + 10) % 360;
  }

  void Pyramide::draw(void)
  {
    glPushMatrix();
    glLoadIdentity();
    glTranslatef(600.0f, 0.0f, -900.0f);
    glRotatef(this->rotation_.y, 0.0f, 1.0f, 0.0f);
    glRotatef(this->rotation_.x, 1.0f, 0.0f, 0.0f);

    glBegin(GL_TRIANGLES);
    glColor3f(1.0f, 1.0f, 1.0f);
    glVertex3f(0.0f, -150.0f, -150.0f);
    glVertex3f(-150.0f, -150.0f, 150.0f);
    glVertex3f(150.0f, -150.0f, 150.0f);
    glColor3f(1.0f, 0.0f, 0.0f);
    glVertex3f(0.0f, 150.0f, 0.0f);
    glVertex3f(-150.0f, -150.0f, 150.0f);
    glVertex3f(150.0f, -150.0f, 150.0f);
    glColor3f(0.0f, 1.0f, 0.0f);
    glVertex3f(0.0f, 150.0f, 0.0f);
    glVertex3f(0.0f, -150.0f, -150.0f);
    glVertex3f(-150.0f, -150.0f, 150.0f);
    glColor3f(0.0f, 0.0f, 1.0f);
    glVertex3f(0.0f, 150.0f, 0.0f);
    glVertex3f(150.0f, -150.0f, 150.0f);
    glVertex3f(0.0f, -150.0f, -150.0f);
    glEnd();
    glPopMatrix();
  }
}
